package com.mongodb.config;

import com.mongodb.document.geoJson.CustomGeoJson;
import org.bson.Document;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;

/**
 * @author zhangbowen
 * @date 2019/5/9
 **/
@Configuration
//@WritingConverter
public class CustomWriteGeoJsonConverter implements Converter<CustomGeoJson, Document> {
    @Override
    public Document convert(CustomGeoJson geoJson) {
        Document document = new Document();
        document.put("type", geoJson.getType());
        document.put("coordinates", geoJson.getCoordinates());
        return document;
    }
}
